<template>
  <view class="tradeDetail">
    <!-- 头部 -->
		<view class="header_bar header_fixed header_main">
			<view class="header">
				<view class="header-goBack" @tap.stop="$tools.back(1)"></view>
				<view class="header-title">明细</view>
			</view> 
    </view> 
    <view class="tradeDetail-list" v-if="isShowPage">
      <view class="tradeDetail-list_item" v-for="(item,index) in list" :key="index">
        <view v-if="type==1">给用户{{item.sellAccount | conceal(4)}}支付<text class="red">{{item.amount}}</text>积分</view>
        <view v-if="type==2">用户{{item.buyAccount | conceal(4)}}给我支付<text class="red">{{item.amount}}</text>积分</view>
      </view>
    </view>
  </view>
</template>

<script>
export default {
  data () {
    return {
      isShowPage:true,
      id:'',
      pageSize:10,
      pageIndex:1,
			type:1,
      list:[],
    };
},
  onLoad(options) {
    if(options){
      this.id = options.value1
      this.type = options.value2>1?2:1
      this.init()
    }
  },
  // 下拉刷新
	onPullDownRefresh() {
			this.init();
		setTimeout(function () {
			uni.stopPullDownRefresh();
		}, 500);
	},
  onReachBottom() {
    console.log("ddd");
    if (this.pageIndex >= this.pages) {
      return this.$tools.toast('到底了');
    } else {
      this.pageIndex++;
      console.log("+++")
      this.getRecord();
    }
  },
  methods: {
    init(){
				this.isShowPage = false;
				this.pageSize = 10;
				this.pageIndex = 1;
				this.list = [];
				this.getRecord();
		},
    // 记录
    getRecord(){
      var data = {
        orderId:this.id,
        type:this.type
      };
      console.log("data：",data);
      uni.showLoading({
        mask:true
      })
      this.$Ajax('/api/mate/mateRecord',data, res => {
          if(res.code == 200){
            this.isShowPage = true;
            this.pages = res.data.pages;
            this.list = res.data;
            uni.hideLoading();
          }
        }, err => {
          uni.hideLoading();
        }, 'GET'
      );
    },
  },
};
</script>

<style lang="scss" scoped>
.tradeDetail{
  overflow: hidden;
  padding-bottom: 24rpx;
  &-list{
    &_item{
      width: 91.4%;
      margin: auto;
      margin-top: 24rpx;
      background: #fff;
      border-radius: 16rpx;
      padding: 32rpx;
      font-weight: 500;
      font-size: 28rpx;
      color: #333333;
      font-weight: bold;
      text-align: center;
    }
  }
  .red{
    color: #FA6A45 ;
  }
}
</style>
